package ch.zbw.sysventory.server.scanner;

import java.util.Enumeration;

public class IPManager implements Enumeration<String> {
	private int end = 0;
	private int first = 0;
	private String nextIP = "";

	public IPManager(String firstIP, String lastIP) {
		first = 0;
		this.nextIP = firstIP;
		end = IPHelper.getTotalCountOfIPsInRange(firstIP, lastIP);
	}

	public boolean hasMoreElements() {
		return !(first == end);
	}

	public String nextElement() {
		if (first > 0) {
			nextIP = IPHelper.getNextIP(nextIP);
		}

		first++;
		return nextIP;
	}
}
